<?

require_once ("application.fieldset.inc");

global $_GLOBAL_DBH;
global $_OBJECT_IFACE_PANEL;

$fieldset = new Fieldset (array (
	db_conn=>$_GLOBAL_DBH,
	relation=>"users",
	fieldset=>array (
		array (name=>"id",label=>"ID",type=>"numeric",
				value=>$_REQUEST["user_id"],
				input=>"hidden",primary_key=>true),
		array (name=>"passwd",label=>"Password",type=>"alphanumeric",
				input=>"password",value=>crypt ($_REQUEST["passwd"], "SC")),
		array (name=>"passwd_ver",label=>"Verify Password",type=>"alphanumeric",
				input=>"password"),
	)
));

$fieldset->parse ();

$return = "/fs_users.php?fs_tab=password&fs_tab_option=lc_password&user_id=" . $_REQUEST["user_id"];

$valid = false;

if (isset ($_REQUEST["passwd"]) && isset ($_REQUEST["passwd_ver"]))

	if ($_REQUEST["passwd"] == $_REQUEST["passwd_ver"]) {
		$fieldset->set_error ("Password updated successfully");
		$fieldset->drop_field ("passwd_ver");
		$fieldset->get_field ("passwd")->set_variable ("value", crypt ($_REQUEST["passwd"], "SC"));
		$valid = true;
	} else $fieldset->set_error ("Passwords do not match");
elseif (!isset ($_REQUEST["passwd"]))

	$fieldset->set_error ("Password must be set");
elseif (!isset ($_REQUEST["passwd_ver"]))

	$fieldset->set_error ("Password Verification must be sett");
else $fieldset->set_error ("Passwords fields are blank");

$fs_options = array (
	addnew=>array (label=>"Add State"),
	create=>array (label=>"Create"),
	modify=>array (label=>"Modify"),
	remove=>array (label=>"Remove"),
	update=>array (label=>"Update"),
	cancel=>array (label=>"Cancel"),
	delete=>array (label=>"Delete",
			redirect=>dirname ($_SERVER["PHP_SELF"]) . $return),
	canret=>array (label=>"Cancel",
			redirect=>dirname ($_SERVER["PHP_SELF"]) . $return),
	close=>array (label=>"Close",
			redirect=>dirname ($_SERVER["PHP_SELF"]) . $return),
);

$image_options = array (size=>$_REQUEST["_img_size"]);

if ($valid) list ($fs_input, $fs_action, $store, $valid, $success) =

	_app_process_fieldset (array (
		fieldset=>$fieldset,
		fs_options=>$fs_options,
		fs_action=>($_REQUEST["fs_action"] ?
				$_REQUEST["fs_action"] :
				"modify"),
)); else { $fs_input = true; $fs_action = "modify"; }

$_OBJECT_FIELDSET_CONTROL =_app_create_fieldset_object (array (
	fieldset_id=>"fs_user_password",
	db_conn=>$_GLOBAL_DBH,
	fieldset=>$fieldset,
	fs_enctype=>"multipart/form-data",
	fs_action=>$fs_action,
	fs_input=>$fs_input,
	fs_link=>"fs_users.php?fs_tab=password&fs_tab_option=fs_password&user_id=" . $_REQUEST["user_id"],
	fs_callback_create=>"_app_create_picture",
	fs_options=>$fs_options,
));

$_OBJECT_IFACE_TABBING_PANEL->insert_container ($_OBJECT_FIELDSET_CONTROL);

?>
